package com.cavalier.surtr.ucCenterController;

import com.alibaba.fastjson.JSON;
import com.cavalier.surtr.commonBase.ProcessResult;
import com.cavalier.surtr.query.ucCenter.UserQuery;
import com.cavalier.surtr.rpcBO.ucCenter.UserBO;
import com.cavalier.surtr.rpcService.ucCenter.IUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by archangle on 17/3/8.
 */
@RestController
@RequestMapping("user")
public class UserController {

    private static Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private IUserService userService;

    @RequestMapping("/addUser")
    @ResponseBody
    ProcessResult<UserBO> addUser(@RequestBody UserQuery userQuery) {
        logger.info(this.getClass().getSimpleName() + "的方法调用入参：" + JSON.toJSONString(userQuery));
        UserBO userBO = new UserBO();
        BeanUtils.copyProperties(userQuery, userBO);
        return userService.addUser(userBO);
    }
}
